﻿using System;
using GeoAPI.Geometries;
using NetTopologySuite.Algorithm;
using NetTopologySuite.GeometriesGraph;

namespace NetTopologySuite.Operation
{
	public class GeometryGraphOperation
	{
		protected LineIntersector lineIntersector
		{
			get
			{
				return this._li;
			}
			set
			{
				this._li = value;
			}
		}

		public GeometryGraphOperation(IGeometry g0, IGeometry g1) : this(g0, g1, BoundaryNodeRules.OgcSfsBoundaryRule)
		{
		}

		public GeometryGraphOperation(IGeometry g0, IGeometry g1, IBoundaryNodeRule boundaryNodeRule)
		{
			this._li = new RobustLineIntersector();
			//base..ctor();
			if (g0.PrecisionModel.CompareTo(g1.PrecisionModel) >= 0)
			{
				this.ComputationPrecision = g0.PrecisionModel;
			}
			else
			{
				this.ComputationPrecision = g1.PrecisionModel;
			}
			this.arg = new GeometryGraph[2];
			this.arg[0] = new GeometryGraph(0, g0, boundaryNodeRule);
			this.arg[1] = new GeometryGraph(1, g1, boundaryNodeRule);
		}

		public GeometryGraphOperation(IGeometry g0)
		{
			this._li = new RobustLineIntersector();
			//base..ctor();
			this.ComputationPrecision = g0.PrecisionModel;
			this.arg = new GeometryGraph[1];
			this.arg[0] = new GeometryGraph(0, g0);
		}

		public IGeometry GetArgGeometry(int i)
		{
			return this.arg[i].Geometry;
		}

		protected IPrecisionModel ComputationPrecision
		{
			get
			{
				return this.resultPrecisionModel;
			}
			set
			{
				this.resultPrecisionModel = value;
				this.lineIntersector.PrecisionModel = this.resultPrecisionModel;
			}
		}

		private LineIntersector _li;

		protected IPrecisionModel resultPrecisionModel;

		protected GeometryGraph[] arg;
	}
}
